// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.2 OR LicenseRef-Slint-commercial

component Clip {
    // the presence of a Clip element should not impact the rest
}


MaybeVisible := Rectangle {
    width: 10phx;
    height: 10phx;
    property <int> touch;
    out property has-hover <=> ta.has-hover;
    Rectangle {
        background: red;
        x: 5phx;
        y: -10phx;
        width: 15phx;
        height: 15phx;
        ta := TouchArea {
            clicked => { touch+=1; }
        }
    }
}

Invisible := TouchArea {
    visible: false;
}

component VisibleAlias {
    in property v <=> r.visible;
    r := Rectangle {
        TouchArea {
            clicked => {
                debug("Error");
            }
        }
    }
}

TestCase := Rectangle {
    height: 100phx;
    width: 100phx;
    property <int> touch1 <=> el1.touch;
    property <int> touch2 <=> el2.touch;
    property <bool> el1visible : true;
    out property el1-has-hover <=> el1.has-hover;

    el1 := MaybeVisible {
        visible <=> el1visible;
        x: 10phx;
        y: 10phx;
    }

    el2 := MaybeVisible {
        visible: false;
        x: 30phx;
        y: 30phx;
    }

    Invisible {  }

    VisibleAlias { v:false; width: 100%; height: 100%; }

    test_rect := Rectangle { }
    property <bool> test: test_rect.visible && !el2.visible && el1.visible;
}

/*
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;

assert_eq(instance.get_test(), true);
assert_eq(instance.get_el1visible(), true);

// el2 !visible, outside
slint_testing::send_mouse_click(&instance, 37., 27.);
assert_eq(instance.get_touch1(), 0);
assert_eq(instance.get_touch2(), 0);
assert(!instance.get_el1_has_hover());

// el2 !visible, inside
slint_testing::send_mouse_click(&instance, 37., 33.);
assert_eq(instance.get_touch1(), 0);
assert_eq(instance.get_touch2(), 0);
assert(!instance.get_el1_has_hover());


// el1 visible, outside
slint_testing::send_mouse_click(&instance, 17., 7.);
assert_eq(instance.get_touch1(), 1);
assert_eq(instance.get_touch2(), 0);
assert(instance.get_el1_has_hover());

// el1 visible, inside
slint_testing::send_mouse_click(&instance, 17., 13.);
assert_eq(instance.get_touch1(), 2);
assert_eq(instance.get_touch2(), 0);
assert(instance.get_el1_has_hover());

// now makes el invisible
instance.set_el1visible(false);
slint_testing::send_mouse_click(&instance, 17., 7.);
assert_eq(instance.get_touch1(), 2);
assert_eq(instance.get_touch2(), 0);
assert(!instance.get_el1_has_hover());

```


```rust
let instance = TestCase::new().unwrap();


assert_eq!(instance.get_test(), true);
assert_eq!(instance.get_el1visible(), true);

// el2 !visible, outside
slint_testing::send_mouse_click(&instance, 37., 27.);
assert_eq!(instance.get_touch1(), 0);
assert_eq!(instance.get_touch2(), 0);

// el2 !visible, inside
slint_testing::send_mouse_click(&instance, 37., 33.);
assert_eq!(instance.get_touch1(), 0);
assert_eq!(instance.get_touch2(), 0);
assert!(!instance.get_el1_has_hover());


// el1 visible, outside
slint_testing::send_mouse_click(&instance, 17., 7.);
assert_eq!(instance.get_touch1(), 1);
assert_eq!(instance.get_touch2(), 0);
assert!(instance.get_el1_has_hover());

// el1 visible, inside
slint_testing::send_mouse_click(&instance, 17., 13.);
assert_eq!(instance.get_touch1(), 2);
assert_eq!(instance.get_touch2(), 0);
assert!(instance.get_el1_has_hover());

// now makes el invisible
instance.set_el1visible(false);
slint_testing::send_mouse_click(&instance, 17., 7.);
assert_eq!(instance.get_touch1(), 2);
assert_eq!(instance.get_touch2(), 0);
assert!(!instance.get_el1_has_hover());
```

*/
